package com.example.demo810.api;

import com.example.demo810.biz.TestService;
import com.example.demo810.vo.AjaxResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lzh
 * @date 2020/8/11 - 16:04
 */
@Api(tags = "security权限注解测试")
@RestController
public class TestController {

    //------secutity权限注解测试--------------------------------------------
    @Autowired
    TestService testService;

    @ApiOperation("注解PreAuthorize测试")
    @GetMapping("/any/hello")
    public AjaxResponse<Void> hello(@RequestHeader String accessToken) {
        return AjaxResponse.successMsg(testService.testAny());
    }

    @ApiOperation("注解 Secured 测试")
    @GetMapping("/admin/hello")
    public AjaxResponse<Void> hello2(@RequestHeader String accessToken) {
        return AjaxResponse.successMsg(testService.testAdmin());

    }

    @ApiOperation("AND权限测试")
    @GetMapping("/and/hello")
    public AjaxResponse<Void> hello3(@RequestHeader String accessToken) {
        return AjaxResponse.successMsg(testService.testAnd());
    }

    @GetMapping("/user/hello")
    @ApiOperation("user权限测试")
    public AjaxResponse<Void> hello4(@RequestHeader String accessToken) {
        return AjaxResponse.successMsg(testService.testUser());
    }
}
